window.onload=init();
function init() {
    authenticate();
    var hrefs=location.href.split("/");
    var id = hrefs.pop();
    fillingArticle(id);
    fillingHotTopicNews(4);
}

function fillingArticle(id) {
    $.ajax({
        url:"/news/"+id,
        dataType:"json",
        contentType:"application/json;charset=utf-8",
        type:"POST",
        success:function (response) {
            console.log(response);
            appendArticle(response.data);
        },
        error:function (request) {
            console.log(request);
        }
    });
}

function appendArticle(data) {
    $(".title_").text(data.title);
    $(".publishTime").text(data.publishTime);
    $(".author").text(data.author);
    $(".article").html(data.content);
    $(".readCount").text(data.readCount);
    $(".image").empty();
    var info = " <img style=\"width: 100%\" src=\"" + data.imageUrl + "\" alt=\"#\"></a>";
    $(".image").append(info);
    $(".url").attr("href",data.url);
    $(".url").text(data.url);
}